﻿@page
@model RazorPages.Pages.StuPage.IndexModel
<h1 class="text-info">学生列表</h1>
<br />
<div class="container p-0 m-0">

    <div class="row">
        <div class="col-2">
            @*<a asp-page="Create" class="btn-link">添加学生</a>*@
            <h3><a asp-page="Create" class="text-primary">添加学生</a></h3>
        </div>

        <div class="col-5 offset-5">
            <form method="get">
                <div class="input-group">
                    <input class="form-control w-25" asp-for="name" placeholder="请输入姓名" />
                    @*<div class="input-group-append">
                        <button class="btn btn-primary">查询</button>
                    </div>*@
                    &nbsp;&nbsp;
                    @*<input class="form-control w-25" asp-for="stucls" placeholder="请输入班级" />*@
                    <select class="custom-select" asp-for="ClsId" asp-items="Model.Classlist">
                        <option value="">请选择班级</option>
                    </select>
                    <div class="input-group-append">
                        <button class="btn btn-primary">查询</button>
                    </div>
                </div>
            </form>
        </div>


    </div>

    <br />
    @* 如果要提交数据必须要form表单包裹起来*@
    <form method="post">
        <table class="table">
            <thead class="thead-dark w-100">
                <tr>
                    <th><label scope="col" asp-for="Stus.FirstOrDefault().StudentId"></label></th>
                    <th><label scope="col" asp-for="Stus.FirstOrDefault().StudentName"></label></th>
                    <th><label scope="col" asp-for="Stus.FirstOrDefault().Gender"></label></th>
                    <th><label scope="col" asp-for="Stus.FirstOrDefault().Birthday"></label> </th>
                    <th><label scope="col" asp-for="Stus.FirstOrDefault().StudentIdNo"></label></th>
                    <th><label scope="col" asp-for="Stus.FirstOrDefault().CardNo"></label></th>
                    <th><label scope="col" asp-for="Stus.FirstOrDefault().StuImage"></label></th>
                    <th><label scope="col" asp-for="Stus.FirstOrDefault().Age"></label></th>
                    <th><label scope="col" asp-for="Stus.FirstOrDefault().PhoneNumber"></label></th>
                    <th><label scope="col" asp-for="Stus.FirstOrDefault().StudentAddress"></label></th>
                    <th><label scope="col" asp-for="Stus.FirstOrDefault().ClassId"></label></th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
                @foreach (var item in Model.Stus)
                {
                    <tr>
                        <th scope="row">@item.StudentId</th>
                        <td>@item.StudentName</td>
                        <td>@item.Gender</td>
                        <td>@item.Birthday</td>
                        <td>@item.StudentIdNo</td>
                        <td>@item.CardNo</td>
                        <td>@item.StuImage</td>
                        <td>@item.Age</td>
                        <td>@item.PhoneNumber</td>
                        <td>@item.StudentAddress</td>
                        <td>@item.Class.ClassName</td>
                        <td>
                            @*调用 OnPostDelete*@
                            <button asp-page-handler="Delete" asp-route-id="@item.StudentId" class="btn btn-danger btn-sm" onclick="return confirm('确定删除？')">删除</button>
                            <a asp-page="Edit" asp-route-id="@item.StudentId" class="btn btn-success btn-sm">修改</a>
                        </td>
                    </tr>
                }

            </tbody>
        </table>
    </form>


</div>
